﻿
//函数

var printflag;
//-----------------------住宅---------------------
function dialog_homesearch_show() {
    $('#dialog-homesearch').dialog({modal:true});
     $('#cbarea').combobox({url:'../Controller.aspx?controller=RoomController&method=GetCombAreaList'});
     $('#cbbuild').combobox({url:'../Controller.aspx?controller=RoomController&method=GetBuildingFieldList&AreaCode='});
}

function dialog_homesearch_close() {
    $('#dialog-homesearch').dialog('close');
}

function debthome_show(){  
    dialog_homesearch_show();
}

function loadBuild(){
	$('#cbarea').combobox({
		onSelect: function(record) {
		  var s=record.AreaCode;
           $('#cbbuild').combobox('options').url = '../Controller.aspx?controller=RoomController&method=GetBuildingFieldList&AreaCode=' + s;
           $('#cbbuild').combobox('reload');
       }
	});
}

function dialog_homesearch_queding()
{
     printflag=1;
      var searchArea = $('#cbarea').combobox('getValue');
      var searchBuilding = $('#cbbuild').combobox('getValue');
      var searchRoom = $('#roomname').val();
      $('#debtgrid').treegrid('options').url = '../Controller.aspx?controller=PrintDebtformController&method=GetHomeDebtList&AreaCode='+searchArea+'&BuildingCode='+searchBuilding+'&RoomName='+searchRoom;
      $('#debtgrid').treegrid('reload');
       dialog_homesearch_close(); 
}
//------------------------------------------------

//-----------------------门面---------------------
function dialog_shopsearch_show() {
    $('#dialog-shopsearch').dialog({modal:true});
}

function dialog_shopsearch_close() {
    $('#dialog-shopsearch').dialog('close');
}

function debtshop_show(){  
    dialog_shopsearch_show();
}

function dialog_shopsearch_queding()
{
       printflag=2;
      var shopName = $('#txtshop').val();
      $('#debtgrid').treegrid('options').url = '../Controller.aspx?controller=PrintDebtformController&method=GetShopDebtList&ShopName='+shopName;
      $('#debtgrid').treegrid('reload'); 
      dialog_shopsearch_close();
}
//------------------------------------------------


//-----------------------车位---------------------
function dialog_carsearch_show() {
    $('#dialog-carsearch').dialog({modal:true});
     $('#carareacode').combobox({url:'../Controller.aspx?controller=CarportController&method=GetCarAreaList'});
}

function dialog_carsearch_close() {
    $('#dialog-carsearch').dialog('close');
}

function debtcar_show(){  
    dialog_carsearch_show();
}


function dialog_carsearch_queding()
{
      printflag=3;
      var searchArea = $('#carareacode').combobox('getValue');
      var carcode = $('#carcode').val();
      $('#debtgrid').treegrid('options').url = '../Controller.aspx?controller=PrintDebtformController&method=GetCarPortDebtList&CarAreaCode='+searchArea+'&CarCode='+carcode;
      $('#debtgrid').treegrid('reload'); 
       dialog_carsearch_close();
}
//------------------------------------------------


//-----------------------客户---------------------
function dialog_clientsearch_show() {
    $('#dialog-clientsearch').dialog({modal:true});
}

function dialog_clientsearch_close() {
    $('#dialog-clientsearch').dialog('close');
}

function debtclient_show(){  
    dialog_clientsearch_show();
}

function dialog_clientsearch_queding()
{
     printflag=4;
      var clientname = $('#clientname').val();
      $('#debtgrid').treegrid('options').url = '../Controller.aspx?controller=PrintDebtformController&method=GetClientDebtList&ClientName='+clientname;
      $('#debtgrid').treegrid('reload'); 
      dialog_clientsearch_close();
}
//------------------------------------------------


function printdebt()
{
    $.messager.progress({
        title: '查询',
        msg: '正在查询中，请等待...'
    });
    requestAjax('../Controller.aspx?controller=PrintDebtformController&method=GetDebtData', { PrintFlag: printflag }, function() {
        printDialogPreview( '../../Report/');
        $.messager.progress('close');
    }, function() { $.messager.progress('close'); });
}

//初始入口
$(function() {
   dialog_homesearch_close();
   dialog_shopsearch_close();
   dialog_carsearch_close();
   dialog_clientsearch_close();
   loadBuild();
});
